home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 10 / FM Towns Free Software Collection 10.iso / ms_dos / tool / fapxtool / src / txl / txldll.c < prev    next >
C/C++ Source or Header  |  1995-02-11  |  3KB  |  148 lines

  1. /***************
  2. *
  3. * g:\exe\txl\src\txldll.c
  4. */
  5. #include "txl.h"
  6.  
  7. char dllform[68]= "%%-%%-%% %%:%% $$$$$$$$$$$$ $             %%%% $$$$$$$$$$$$ %%%%.% ";
  8.  
  9. void marklist(int *dlst, FILE *fp, FILE *fw, int maxno)
  10. {
  11.     int i = 0, listno;
  12.  
  13.     while (!feof(fp)) {
  14.         fgets(line1, 80, fp);
  15.         if (sscanf(line1, "%d", &listno)) {
  16.             while (((dlst[i]) & 0x3fff) > listno) {
  17.                 i++;
  18.             }
  19.             if (((dlst[i]) & 0x3fff) == listno) {
  20.                 if (*(line1+4) != ' ') {
  21.                     *(line1+4) = ' ';
  22.                 }
  23.                 else {
  24.                     *(line1+4) = (((dlst[i]) & 0x8000) ? '!' : 
  25.                                 (((dlst[i]) & 0x4000) ? '・' : '#'));
  26.                 }
  27.             }
  28.         }
  29.         fputs(line1, fw);
  30.     }
  31. }
  32.  
  33. int readdownlist(int *dlst, FILE *fp)
  34. {
  35. /*
  36. 1994-03-02 07:16 FLABO      2  1125  XSORT100.LZH    7803    48    162
  37. %%%%-%%-%% %%:%%               %%%%  $$$$$$$$$$$$ %%%%%%% %%%%%  %%%%%
  38. 1994-03-02 07:16 FLABO      2  1125  XSORT100.GGG    2128  ----    ---
  39. */
  40. /* ニューバージョン
  41.   日 付  時 刻  電話番号 ROAD FORUM名  DL  No.  ファイル名 サイズ[KB]  時 間  レート
  42. 94-06-26 05:59 xxxx-xx-xxxx x FLABO     2 1664 QKC190.GGG      0.9             
  43. 94-06-20 07:05      99-0200 2 FRAV     12  152 MPTW23BI.LZH   69.1    6:07  192
  44. 94-08-23 07:30      99-0200 2 BMAIL            FPX419メモ.LZH    0.5      11   42
  45. 94-07-21 06:36 ------------ - FRAV     12  167 MPTW23KP.LZH  107.4 ------- ----
  46. */
  47.     int i;
  48.     char *tmp;
  49.  
  50.     sprintf(log_libstr, "%2d", log_libno);
  51.     for (tmp = log_fname, i = 30; *tmp != NUL; tmp++, i++) {
  52.         dllform[i] = *tmp;
  53.     }
  54.     for (tmp = log_libstr, i = 39; *tmp != NUL; tmp++, i++) {
  55.         dllform[i] = *tmp;
  56.     }
  57.     i = 0;
  58.     while (!feof(fp)) {
  59.         fgets(line1, 80, fp);
  60.         if (matchstr(dllform, line1)) {
  61.             sscanf(line1 + 42, "%d", &(dlst[i]));
  62.             if (*(line1 + 78) == '-') {
  63.                 dlst[i] |= 0x8000;
  64.             }
  65.             if (*(line1 + 78) == ' ') {
  66.                 dlst[i] |= 0x4000;
  67.             }
  68.             i++;
  69.         }
  70.     }
  71.     return (i);
  72. }
  73.  
  74. int cmpdll(int *x, int *y)
  75. {
  76.     int ret;
  77.  
  78.     ret = ((*y) & 0x3fff) - ((*x) & 0x3fff);
  79.     if (!ret) {
  80.         if ((*y)^(*x)) {
  81.             if ((*y) & 0x0C000) {
  82.                 return (-1);
  83.             }
  84.             else {
  85.                 return (1);
  86.             }
  87.         }
  88.     }
  89.     return (ret);
  90. }
  91.  
  92. void dllmark()
  93. {
  94.     FILE *fl, *fr;
  95.     int *dlst;
  96.     int maxno;
  97.  
  98.     if ((dlst = calloc(1024, 2)) ==NULL) {
  99.         errexit("out of memory");
  100.     }
  101.     if ((fl = fopen(outputfile, "rt")) == NULL) {
  102.         fprintf(fpmes, "TXL:can't open '%s'", outputfile);
  103.         free(dlst);
  104.         Exit(1);
  105.     }
  106.     if ((fr = fopen(inputfile, "rt")) == NULL) {
  107.         fprintf(fpmes, "TXL:can't open '%s'", inputfile);
  108.         fclose(fl);
  109.         free(dlst);
  110.         Exit(1);
  111.     }
  112.     fgets(line1, 80, fl);
  113.     if (sscanf(line1, "FORUM:%s LIB:%d", log_fname, &log_libno) < 2) {
  114.         free(dlst);
  115.         errexit("checking logfile!!(Is it liblist ?)");
  116.     }
  117.     fputs(line1, fpmes);
  118.  
  119.     do {
  120.         fgets(line1, 80, fl);
  121.         fputs(line1, fpmes);
  122.     } while(jstrncmp(line1, "番号", 2) && !feof(fl));    /* 空読み */
  123.     maxno = readdownlist(dlst, fr);
  124.     fclose(fr);
  125.  
  126.     qsort(dlst, maxno, sizeof(int), cmpdll);
  127.  
  128.     marklist(dlst, fl, fpmes, maxno);
  129.     fclose(fl);
  130.     fclose(fpmes);
  131.     free(dlst);
  132. }
  133.  
  134. void dllinit()
  135. {
  136. /*    fprintf(stderr, "TXL: open DownLoadListMarker\n");    */
  137. }
  138.  
  139. void dlldriver(char *val[])
  140. {
  141.     dllinit();
  142.  
  143.     inputfile = val[0];        /* downlist.dat */
  144.     outputfile = val[1];    /* logfile        */
  145.     dllmark();
  146.     Exit(0);
  147. }
  148.